﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jzy.Core.Common.Web;
using Jzy.Core.Common;

using Jzy.Workflow.Flow;
using Frame.Lib.Enums;
using Frame.Lib.Web;
using Frame.Lib.Common;
using Frame.Lib.Utilities;

namespace Jzy.Web.WorkFlow.Design
{
    public partial class TabItems : System.Web.UI.UserControl
    {
        public string TabIndex
        {
            get;
            set;
        }

        private string FlowID
        {
            get
            {
                return Request.QueryString["FlowID"];
            }
        }

        protected string GetClass(object tabIndex)
        {
            if (tabIndex.ToString() == this.TabIndex)
            {
                return "on";
            }
            else
            {
                return "";
            }
        }

        protected string GetUrl(object tabIndex)
        {
            if (tabIndex.ToString() == this.TabIndex)
            {
                return "javascript:;";
            }
            else
            {
                if (string.IsNullOrEmpty(FlowID))
                {
                    return "javascript:alert(\"请先保存基础信息\")";
                }
                else
                {
                    FlowInfo flowInfo = (new FlowBO()).GetInfo(FlowID);
                    if (string.IsNullOrEmpty(flowInfo.FormTemplate) && int.Parse(tabIndex.ToString()) == (int)FlowTab.表单设置)
                    {
                        return "javascript:alert(\"请先上传表单\")";
                    }
                    else
                    {
                        return "tab" + (((int)tabIndex) + 1) + ".aspx?FlowID=" + FlowID;
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            CssFileManager.AddCssFile(CssFile.tab1);
            //if (!IsPostBack)
            //{
                BindList();
            //}
        }
        private void BindList()
        {
            List<EnumInfo> list = ConvertUtil.ConvertEnum(typeof(FlowTab));
            rpt.DataSource = list;
            rpt.DataBind();
        }
    }
}